home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / utils / file / logiso.000 / logiso / Utils / RCS / install_dir,v < prev    next >
Encoding:
Text File  |  1995-03-24  |  5.9 KB  |  272 lines

  1. head    1.5;
  2. access;
  3. symbols
  4.     VER_0_3:1.5
  5.     VER_0_2:1.4;
  6. locks; strict;
  7. comment    @# @;
  8.  
  9.  
  10. 1.5
  11. date    95.03.24.11.43.35;    author coulter;    state Exp;
  12. branches;
  13. next    1.4;
  14.  
  15. 1.4
  16. date    95.03.10.02.42.22;    author coulter;    state Exp;
  17. branches;
  18. next    1.3;
  19.  
  20. 1.3
  21. date    95.02.19.16.06.41;    author coulter;    state Exp;
  22. branches;
  23. next    1.2;
  24.  
  25. 1.2
  26. date    95.02.19.10.13.26;    author coulter;    state Exp;
  27. branches;
  28. next    1.1;
  29.  
  30. 1.1
  31. date    95.02.18.08.36.38;    author coulter;    state Exp;
  32. branches;
  33. next    ;
  34.  
  35.  
  36. desc
  37. @install a directory on the hard disk.
  38. @
  39.  
  40.  
  41. 1.5
  42. log
  43. @Checkin version for 0.3 distribution.
  44. @
  45. text
  46. @# !/bin/ksh
  47. USAGE=\
  48. 'USAGE: install_dir [ -d config_prefix ] dest_dir_path mount_path map_to_path
  49.    If dest_dir_path is actually a directory below mount_path, duplicate 
  50.    directories below map_to_path to make dest_dir_path be below
  51.    map_to_path.
  52. '
  53. # (C) Copyright 1995 by Michael Coulter.  All rights reserved.
  54. # Basically we create on or for a directory many simple links and then use
  55. # check_links or check_one_link to fix up the link.
  56. set -P # print absolut hw path
  57.  
  58. # Define std functions
  59.  
  60.    ISOFS_UTIL_DIR="${ISOFS_UTIL_DIR:-/usr/src/linux/fs/isofs/Utils}"
  61.    . "$ISOFS_UTIL_DIR/ksh_fns"
  62.  
  63. # Process parameters
  64.  
  65.    CONFIG_PREFIX=""
  66.    if [ $# -ge 2 -a "$1" = "-d" ]
  67.    then
  68.       shift  # done with -d
  69.       CONFIG_PREFIX="$1"; shift
  70.    fi
  71.    if [ $# -ne 3 ]
  72.    then
  73.       echo "$USAGE" >&2
  74.       echo "$0 Expected 3 parameters, got $#" >&2
  75.       exit 1
  76.    fi
  77.    DEST_DIR_PATH="$1"; shift
  78.    MOUNT_PATH="$1"; shift
  79.    MAP_TO_PATH="$1"; shift
  80.    if [ ! -d "$DEST_DIR_PATH" ]
  81.    then
  82.       echo "$USAGE" >&2
  83.       echo "$DEST_DIR_PATH is not a directory" >&2
  84.       exit 1
  85.    fi
  86.    if [ "$DEST_DIR_PATH" = "${DEST_DIR_PATH#$MAP_TO_PATH}" ]
  87.    then
  88.       if [ "$DEST_DIR_PATH" = '.' -o "$DEST_DIR_PATH" = '/' ]
  89.       then
  90.          exit 0
  91.       fi
  92.       echo "$USAGE" >&2
  93.       echo "$DEST_DIR_PATH is not below $MAP_TO_PATH" >&2
  94.       exit 1
  95.    fi
  96.  
  97. # Set variables
  98.  
  99.    TEMP_DIR="install_dir.$$"
  100.    HERE="$PWD"
  101.  
  102. # Do it
  103.  
  104.    ##echo "install_dir: $DEST_DIR_PATH"
  105.    check_cmd 1 cd "$DEST_DIR_PATH"
  106.    THERE="$(pwd -H)"
  107.    ##echo "install_dir: THERE is $THERE"
  108.    # If THERE is not below MOUNT_PATH, there is nothing to do
  109.    if [ "$THERE" != "${THERE#$MOUNT_PATH}" ]
  110.    then
  111.       # EQUIV= the mirror of THERE.
  112.       if [ "$MAP_TO_PATH" = "/" ]
  113.       then
  114.      EQUIV="${THERE#$MOUNT_PATH}"
  115.       else
  116.      EQUIV="${MAP_TO_PATH}${THERE#$MOUNT_PATH}"
  117.       fi
  118.       ##echo "install_dir: EQUIV is $EQUIV"
  119.  
  120.       # We need to install THERE.  Do we need to install its parent?
  121.       cd "$(dirname "$EQUIV")"
  122.       if [ "$PWD" != "${PWD#${MOUNT_PATH}}" ]
  123.       then
  124.          ##echo "install_dir: " install_dir "$(dirname "$EQUIV")"  "$MOUNT_PATH"  "$MAP_TO_PATH"
  125.          check_cmd 20 install_dir -d "$CONFIG_PREFIX" "$(dirname "$EQUIV")"  "$MOUNT_PATH"  "$MAP_TO_PATH"
  126.       fi
  127.       cd "$HERE"
  128.  
  129.       DEST_PARENT="$(dirname "$DEST_DIR_PATH")"
  130.       if [ "$DEST_PARENT" != "$(dirname "$EQUIV")" ]
  131.       then
  132.      # We need to install DEST_DIR_PATH.  Do we need to install its parent?
  133.      cd "$DEST_PARENT"
  134.      if [ "$PWD" != "${PWD#${MOUNT_PATH}}" ]
  135.      then
  136.         check_cmd 20 install_dir -d "$CONFIG_PREFIX" "$DEST_PARENT"  "$MOUNT_PATH"  "$MAP_TO_PATH"
  137.      fi
  138.       fi
  139.  
  140.       # Install EQUIV
  141.       if [ ! -d "$EQUIV" ]
  142.       then
  143.          ##echo "install_dir: Processing $DEST_DIR_PATH path $EQUIV " >&2
  144.          echo "should be a directory." >&2
  145.          exit 21
  146.       fi
  147.  
  148.       check_cmd 2 cd "$(dirname "$THERE")"
  149.       THERE_PARENT="$(pwd -H)"
  150.       cd "$HERE"
  151.       if [ -L "$EQUIV" ]
  152.       then
  153.          check_cmd 5 cd "$DEST_PARENT"
  154.          rm -f "$TEMP_DIR"
  155.          check_cmd 6 mkdir "$TEMP_DIR"
  156.          check_cmd 7 cd "$THERE"
  157.          for FILE in * .??* .[^.]
  158.          do
  159.             if [ -e "$FILE" -o -L "$FILE" ]
  160.             then
  161.                ##echo install_dir: ln -s "${THERE}/${FILE}" "${DEST_PARENT}/${TEMP_DIR}/${FILE}"
  162.                ln -s "${THERE}/${FILE}" "${DEST_PARENT}/${TEMP_DIR}/${FILE}"
  163.             fi
  164.          done
  165.          cd "$HERE"
  166.          check_cmd 8 rm -f "$EQUIV"
  167.          check_cmd 12 cd "$DEST_PARENT"
  168.          check_cmd 9 mv "$TEMP_DIR" "$EQUIV"
  169.          check_cmd 10 cd "$HERE"
  170.          ##echo install_dir: check_cmd 11 check_links -d "$CONFIG_PREFIX" "$EQUIV"
  171.          check_cmd 11 check_links -d "$CONFIG_PREFIX" "$EQUIV"
  172.       fi
  173.       if [ -L "$DEST_DIR_PATH" ]
  174.       then
  175.      check_cmd 13 rm -f "$DEST_DIR_PATH"
  176.      check_cmd 14 ln -s "$EQUIV" "$DEST_DIR_PATH"
  177.       fi
  178.    fi
  179.    cd "$HERE"
  180. @
  181.  
  182.  
  183. 1.4
  184. log
  185. @Checkin files modified to make version 0.2
  186. @
  187. text
  188. @d8 1
  189. @
  190.  
  191.  
  192. 1.3
  193. log
  194. @Checkpoint version 0.1
  195. @
  196. text
  197. @d2 2
  198. a3 1
  199. USAGE='USAGE: install_dir dest_dir_path mount_path map_to_path
  200. d18 7
  201. d79 1
  202. a79 1
  203.          check_cmd 20 install_dir "$(dirname "$EQUIV")"  "$MOUNT_PATH"  "$MAP_TO_PATH"
  204. d90 1
  205. a90 1
  206.         check_cmd 20 install_dir "$DEST_PARENT"  "$MOUNT_PATH"  "$MAP_TO_PATH"
  207. d124 2
  208. a125 1
  209.          check_cmd 11 check_links "$EQUIV"
  210. @
  211.  
  212.  
  213. 1.2
  214. log
  215. @checkpoint file.
  216. @
  217. text
  218. @d7 2
  219. d70 1
  220. a70 1
  221.          echo "install_dir: " install_dir "$(dirname "$EQUIV")"  "$MOUNT_PATH"  "$MAP_TO_PATH"
  222. @
  223.  
  224.  
  225. 1.1
  226. log
  227. @Checkpoint version before fixing /usr/bin install
  228. @
  229. text
  230. @d7 6
  231. d32 1
  232. a32 1
  233.       if [ "$DEST_DIR_PATH" = '.' ]
  234. d43 1
  235. d48 2
  236. a49 2
  237.    ## echo "install_dir: $DEST_DIR_PATH"
  238.    cd "$DEST_DIR_PATH"
  239. d51 2
  240. d55 9
  241. d65 8
  242. d74 12
  243. a85 3
  244.       cd "$DEST_PARENT"
  245.       THERE_PARENT="$(pwd -H)"
  246.       if [ "$THERE_PARENT" != "${THERE_PARENT#$MOUNT_PATH}" ]
  247. d87 3
  248. a89 6
  249.          install_dir "$DEST_PARENT" "$MOUNT_PATH" "$MAP_TO_PATH"
  250.          if [ $? -ne 0 ]
  251.          then
  252.             echo "${0}: unable to install directory $DEST_DIR_PATH" >&2
  253.             exit 1
  254.          fi
  255. d91 2
  256. a92 1
  257.       cd "$DEST_PARENT"
  258. d94 2
  259. a95 1
  260.       if [ "$THERE_PARENT" != "${THERE_PARENT#$MOUNT_PATH}" ]
  261. d97 18
  262. a114 2
  263.          echo "Something is wrong $DEST_PARENT is below $MOUNT_PATH" >&2
  264.          exit 1
  265. d118 2
  266. a119 4
  267.          rm "$DEST_DIR_PATH"
  268.          mkdir "$DEST_DIR_PATH"
  269.          cd "$DEST_DIR_PATH"
  270.          duplicate_dir "$THERE" "$MOUNT_PATH" "$MAP_TO_PATH"
  271. @
  272.